import Vue from "vue";
import VueRouter from "vue-router";
//导入组件
import Main from "../views/Main"
import Home from "../views/home/Home";
import Mall from "../views/mall/Mall";
import User from "../views/user/User";
const orignPush  = VueRouter.prototype.push
VueRouter.prototype.push = function push (location){
  return orignPush.call(this,location).catch(err=>err)
}

//加载路由
Vue.use(VueRouter);

//导出并创建路由对象，
export default new VueRouter({
  mode:'history',
  //路由地址
  routes:[
    {
      path:"/",  //默认加载到首页
      name:"Main",
      component:Main,
      children:[
        {
          path:"/", //默认加载首页时加载子路由地址
          name:"Home",
          component:Home
        },
        {
          path:"/mall",
          name:"Mall",
          component:Mall
        },
        {
          path:"/user",
          name:"User",
          component:User
        }
      ]
    }
  ]
})



